package cn.com.app.v320;

import java.util.ArrayList;
import java.util.List;


public class T {

	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		list.add("China");
		list.add("Amarica");
		list.add("Germany");
		list.add("France");
		list.add("Britain");
		
		String str = listToString(list);
		
		System.out.println(str);
	}

	public static String listToString(List<String> list) {
		if (list == null) {
			return null;
		}
		StringBuilder result = new StringBuilder();
		boolean first = true;
		// 第一个前面不拼接","
		for (String string : list) {
			if (first) {
				first = false;
			} else {
				result.append(",");
			}
			result.append(string);
		}
		return result.toString();
	}
}
